template<class T>
void readInVictor16(T myAst[], long indLastMPC, long indLastNumbMPC, string* ids, long nIds)
{
  ifstream myfile ("result_MarcoTargets-2.txt");
  long ind;
  string line;
  char tax[5];
  AsteroidWithPole ast;

  if (myfile.is_open())
  {
    while ( getline (myfile,line))
      {
	if ((line.length()>1)&&(line.at(0)!='#'))
	  {
	    	    // convert linefile to asteroid
	    ast.victorString2Asteroid(line);
	    ast.print();
	    if (ast.Number>0)
	      if (myAst[ast.Number-1].D<=0)
		{
		  myAst[ast.Number-1].D=ast.D;
		  myAst[ast.Number-1].sigmaD=ast.sigmaD;
		  myAst[ast.Number-1].pV=ast.pV;
		  myAst[ast.Number-1].sigmapV=ast.sigmapV;
		}
	  }
      }
    myfile.close();
  } else cout << "file result_MarcoTargets-2.txt not found " <<endl;
}

template<class T>
void readInVictorMarsXFittedEta(T myAst[], long indLastMPC, long indLastNumbMPC, string* ids, long nIds)
{
  ifstream myfile ("MarsX_FittedEta.txt");
  long ind;
  string line;
  char tax[5];
  AsteroidWithPole ast;

  if (myfile.is_open())
  {
    while ( getline (myfile,line))
      {
	if ((line.length()>1)&&(line.at(0)!='#'))
	  {
	    	    // convert linefile to asteroid
	    ast.victorString2Asteroid(line);
	    if (ast.Number>0)
	      //	      if (myAst[ast.Number-1].D<=0)
		{
		  myAst[ast.Number-1].D=ast.D;
		  myAst[ast.Number-1].sigmaD=ast.sigmaD;
		  myAst[ast.Number-1].pV=ast.pV;
		  myAst[ast.Number-1].sigmapV=ast.sigmapV;
		} else
	      	    ast.print();
	  }
      }
    myfile.close();
  } else cout << "file result_MarcoTargets-2.txt not found " <<endl;
}

template<class T>
void readInVictorMarsX(T myAst[], long indLastMPC, long indLastNumbMPC, string* ids, long nIds)
{
  ifstream myfile ("MX_AliLagoa_Delbo2016.txt");
  long ind;
  string line;
  char tax[5];
  AsteroidWithPole ast;

  if (myfile.is_open())
  {
    while ( getline (myfile,line))
      {
	if ((line.length()>1)&&(line.at(0)!='#'))
	  {
	    	    // convert linefile to asteroid
	    ast.victorString2Asteroid(line);
	    if (ast.Number>0)
	      //	      if (myAst[ast.Number-1].D<=0)
		{
		  myAst[ast.Number-1].D=ast.D;
		  myAst[ast.Number-1].sigmaD=ast.sigmaD;
		  myAst[ast.Number-1].pV=ast.pV;
		  myAst[ast.Number-1].sigmapV=ast.sigmapV;
		} else
	      ast.print();
	  }
      }
    myfile.close();
  } else cout << "file result_MarcoTargets-2.txt not found " <<endl;
}

template<class T>
void readInVictorMarsCrosser2016(T myAst[], long indLastMPC, long indLastNumbMPC, string* ids, long nIds)
{
  string line;
  ifstream myfile ("MX_AliLagoa_Delbo2016.txt"); // NEAs FILE 
  long ind;
  AsteroidWithPole ast;

  if (myfile.is_open())
  {
    for (int j=0; j<1; j++)  
      getline (myfile,line) ; // skip header

    while ( getline (myfile,line))
      if (line.length()>1)
	{
	  // convert linefile to asteroid
	  ast.victorMarsCrossersString2Asteroid(line);
      	  // if the asteroid is Numbered in the file assing it
	  if (ast.Number>0)
	    {
	      if (myAst[ast.Number-1].D>0) continue; 
	      myAst[ast.Number-1].D=ast.D;
	      myAst[ast.Number-1].sigmaD=ast.sigmaD;
	      myAst[ast.Number-1].pV=ast.pV;
	      myAst[ast.Number-1].sigmapV=ast.sigmapV;
	      myAst[ast.Number-1].eta=ast.eta;
	      myAst[ast.Number-1].sigmaEta=ast.sigmaEta;
	      myAst[ast.Number-1].pIR=ast.pIR;
	      myAst[ast.Number-1].sigmapIR=ast.sigmapIR;
	      myAst[ast.Number-1].nW1=ast.nW1;
	      myAst[ast.Number-1].nW2=ast.nW1;
	      myAst[ast.Number-1].nW3=ast.nW3;
	      myAst[ast.Number-1].nW4=ast.nW4;
	      myAst[ast.Number-1].sigmapV=ast.sigmapV;
	      myAst[ast.Number-1].refs[3]+=VICTOR;
	    }
	  else
	    {
	      // can you match is right there ?
	      if ((ind = findUnnumberedAst(myAst,ast,indLastMPC,indLastNumbMPC+1))>=0) // YES ! 
		{
		  if (myAst[ind].D>0) continue; 
		  myAst[ind].D=ast.D;
		  myAst[ind].sigmaD=ast.sigmaD;
		  myAst[ind].pV=ast.pV;
		  myAst[ind].sigmapV=ast.sigmapV;
		  myAst[ind].eta=ast.eta;
		  myAst[ind].sigmaEta=ast.sigmaEta;
		  myAst[ind].pIR=ast.pIR;
		  myAst[ind].sigmapIR=ast.sigmapIR;
		  myAst[ind].nW1=ast.nW1;
		  myAst[ind].nW2=ast.nW1;
		  myAst[ind].nW3=ast.nW3;
		  myAst[ind].nW4=ast.nW4;
		  myAst[ind].refs[3]+=VICTOR;
		  //		  cout << ">>match 1  " << ast.pack << endl;
		}
	      else
		{ // the designation could not be matched.
		  // try to see if the asteroid has been numbered LATER
		  ast.findId(ids,nIds);
		  if (ast.Number>0)
		    {
		      if (myAst[ast.Number-1].D>0) continue; 
		      myAst[ast.Number-1].D=ast.D;
		      myAst[ast.Number-1].sigmaD=ast.sigmaD;
		      myAst[ast.Number-1].pV=ast.pV;
		      myAst[ast.Number-1].sigmapV=ast.sigmapV;
		      myAst[ast.Number-1].eta=ast.eta;
		      myAst[ast.Number-1].sigmaEta=ast.sigmaEta;
		      myAst[ast.Number-1].pIR=ast.pIR;
		      myAst[ast.Number-1].sigmapIR=ast.sigmapIR;
		      myAst[ast.Number-1].nW1=ast.nW1;
		      myAst[ast.Number-1].nW2=ast.nW1;
		      myAst[ast.Number-1].nW3=ast.nW3;
		      myAst[ast.Number-1].nW4=ast.nW4;
		      myAst[ast.Number-1].sigmapV=ast.sigmapV;
		      myAst[ast.Number-1].refs[3]+=VICTOR;
		      //		      cout << ">>match 2  " << ast.pack << endl;
		    }
		  else
		    {
		      if ((ind = findUnnumberedAst(myAst,ast,indLastMPC,indLastNumbMPC+1))>=0) // YES ! 
			{
			  if (myAst[ind].D>0) continue; 
			  myAst[ind].D=ast.D;
			  myAst[ind].sigmaD=ast.sigmaD;
			  myAst[ind].pV=ast.pV;
			  myAst[ind].sigmapV=ast.sigmapV;
			  myAst[ind].eta=ast.eta;
			  myAst[ind].sigmaEta=ast.sigmaEta;
			  myAst[ind].pIR=ast.pIR;
			  myAst[ind].sigmapIR=ast.sigmapIR;
			  myAst[ind].nW1=ast.nW1;
			  myAst[ind].nW2=ast.nW1;
			  myAst[ind].nW3=ast.nW3;
			  myAst[ind].nW4=ast.nW4;
			  myAst[ind].refs[3]+=VICTOR;
			  //			  cout << ">>match 23  " << ast.pack << endl;
			}
		      else
			{
			  cout << ">>match FAILED  " << ast.pack << "--" << line << endl;
			}
		    }
		}
	    }
	}
    myfile.close();
  }
  else cout << "Unable to open file"; 
}
